package org.zhadoop.stream.cql.semanticanalyzer.parser.visitor;

import org.antlr.v4.runtime.misc.NotNull;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.DistinctContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.CQLParser.SelectItemContext;
import org.zhadoop.stream.cql.semanticanalyzer.parser.context.SelectClauseContext;

/**
 * select 子语句语法结构遍历
 * @author zwd
 *
 */
public class SelectClauseVisitor extends AbsCQLParserBaseVisitor<SelectClauseContext> {

	private SelectClauseContext context = null;

	public SelectClauseVisitor() {
		context = new SelectClauseContext();
	}

	@Override
	protected SelectClauseContext defaultResult() {
		return context;
	}

	@Override
	public SelectClauseContext visitDistinct(@NotNull DistinctContext ctx) {
		context.setDistinct(true);
		return context;
	}

	@Override
	public SelectClauseContext visitSelectItem(SelectItemContext ctx) {
		SelectItemVisitor visitor = new SelectItemVisitor();
		context.getSelectItems().add(visitor.visit(ctx));
		return context;
	}

}
